package cn.jiyun.dao;

import cn.jiyun.pojo.Member;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface MemberDao {
    @Select("select * from t_member where phoneNumber = #{telephone}")
    Member findByPhone(String telephone);

    void add(Member member);

    @Select("SELECT COUNT(*) FROM t_member WHERE regTime <= #{regDate}")
    Integer getCountByRegDate(String regDate);

    @Select("SELECT s.`name`,COUNT(*) as num FROM t_order o , t_setmeal  s WHERE o.setmeal_id = s.id GROUP BY s.id ")
    List<Map<String, Object>> getSetmealReport();

    @Select("select count(*) from t_member WHERE regTime = #{todayStr}")
    Integer getTodayNewMember(String todayStr);

    @Select("select count(*) from t_member")
    Integer getTotalMember();

    @Select("select count(*) from t_member WHERE regTime >= #{firstDayOfWeek}")
    Integer getThisWeekNewMember(Date firstDayOfWeek);
}
